<?php
class template_create extends theme
{
	
	protected function head()
	{
	?>
<script type="text/javascript" language="javascript" src="js/jquery.validate.pack.js"></script>

<link type="text/css" rel="stylesheet" href="templates/pricing/css/create.css">
<script type="text/javascript" language="javascript" src="templates/pricing/js/create.js"></script>
	<?php
	$this->load_editor();
	}

	protected function center()
	{
		?>
<div class="center-title"><?php echo $this->title; ?></div>
<div class="center-content">

<?php $this->message();?>

<p class="create-notice">请提交您的项目资料。稍候会有工程师为您报价。请尽可能详细的描述您的项目，同时上传相关的文档， 如素材，参考图片， Word文档，Excel表格，PDF文档等。</p>

<form action="./" method="post" enctype="multipart/form-data" id="form-pricing">
<table class="edit-table">
<tr>
<td class="key">项目名</td>
<td><input type="text" name="name" id="name" style="width:300px;" /></td>
</tr>

<tr>
<td class="key">描述</td>
<td><?php $this->editor('description', '', '100%', '200px'); ?></td>
</tr>

<tr>
<td class="key">上传相关附件</td>
<td>
<div id="attachments">
	<div class="attachment"><input type="file" name="attachment[]" /></div>
</div>
<a href="javascript:;" onclick="javascript:addAttachment()">+ 新增</a>
</td>
</tr>

<?php
$my = bone::get_user();

if($my->guest)
{
?>
<tr>
<td class="key">接收报价到邮箱</td>
<td>
<input type="hidden" name="customer_id" value="0" />
<input type="text" name="customer_email" id="customer_email" style="width:200px;" />
</td>
</tr>
<?php
}
else
{
?>
<input type="hidden" name="customer_id" value="<?php echo $my->id; ?>" />
<input type="hidden" name="customer_email" id="customer_email" value="<?php echo $my->email; ?>" />
<?php
}
?>
<tr>
<td class="key">验证码<br><small>(不区分大小写)</small></td>
<td>
<input type="text" name="captcha" id="captcha" style="width:60px;" maxlength="4" /> &nbsp; 
<img src="./?controller=captcha&task=pricing" align="absmiddle" alt="点击刷新" style="cursor:pointer" id="captcha-img" onClick="this.src='./?controller=captcha&task=pricing&_='+Math.random();" /> &nbsp; 
<a href="javascript:;" onclick="javascript:document.getElementById('captcha-img').src='./?controller=captcha&task=pricing&_='+Math.random();">看不清楚，刷新</a>
</td>
</tr>

<tr>
<td class="key"></td>
<td>
<input class="btn" type="submit" value="提交" />
</td>
</tr>
</table>
<p class="create-notice">允许上传的附件类型: <?php echo ALLOW_UPLOAD_FILE_TYLE;?>, 其它类型附件将被忽略。</p>
<input type="hidden" name="controller" value="pricing" />
<input type="hidden" name="task" value="create_save" />
<input type="hidden" name="menu_id" value="<?php echo request('menu_id'); ?>" />
</form>

</div>
		
		
		
<div class="center-title">最近报价</div>
<div class="center-content">

<div class="pricings">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr height="25">
	<th align="left">项目名</th>
	<th align="center" width="60">客户</th>
	<th align="center" width="70">报价工程师</th>
	<th align="center" width="110">报价时间</th>
	<th align="center" width="60">工期</th>
	<th align="center" width="200">费用</th>
</tr>

<?php
$pricings = $this->get('recent_pricings');

if(count($pricings))
{
$i=0;
foreach($pricings as $pricing)
{
?>
<tr height="25" class="row-<?php echo $i; ?>">
	<td align="left">
	<a href="<?php echo url('./?controller=pricing&task=detail&pricing_id='.$pricing->id.'&menu_id='.$this->get('menu_id') ); ?>" title="<?php echo $pricing->name; ?>" target="_blank">
	<?php echo $pricing->name; ?>
	</a>
	</td>
	<td align="center">
	<?php
	if($pricing->customer_id)
	{
		echo bone::get_user($pricing->customer_id)->name;
	}
	else
	{
		echo '游客';
	}
	?>
	</td>
	<td align="center">
	<?php
	$manager = bone::get_user($pricing->manager_id);
	?>
	<a href="<?php echo url('./?controller=team&task=user_detail&user_id='.$pricing->manager_id); ?>" title="<?php echo $manager->name; ?>" target="_blank">
	<?php echo $manager->name; ?>
	</a>
	</td>
	<td align="center"><?php echo date('Y-m-d',$pricing->price_time); ?></td>
	<td align="center"><?php echo $pricing->estimate_days; ?>天</td>
	<td align="center">
	<?php
	if($pricing->time_total>=3600) echo intval($pricing->time_total/3600).'小时';
	if($pricing->time_total%3600!=0) echo intval($pricing->time_total%3600/60).'分钟';
	
	echo ' X '. $pricing->hourly_rate.'元/小时 =<span class="required">'.number_format($pricing->price, 2).'</span>元';
	?>	
	</td>
</tr>
<?php
$i = 1-$i;
}
}
else
{
?>
<tr height="25">
	<td colspan="6" align="center">暂无记录</td>
</tr>
<?php
}
?>
</table>
</div>

<div class="more-pricing"><a href="<?php echo url('./?controller=pricing&task=listing&menu_id='.request('menu_id') ); ?>" title="更多报价记录">查看更多报价记录...</a></div>

</div>


		<?php
	}		
		

}
?>